<%@page import="com.sdry.model.llm.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>工位：拆端盖（固化绑定）</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/ztree/css/zTreeStyle/zTreeStyle.css">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/css/w4.css">

    <script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.all.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.exedit.js"></script>
	<script src="${pageContext.request.contextPath }/js/jyy/w4.js" charset="utf-8"></script>
	
	<script type="text/javascript">
	var format = "";
	
	//年月日+星期
	function load(){
		format = '${format}';
		var d=new Date(format);
		var day=d.getDate();
		var month=d.getMonth() + 1;
		var year=d.getFullYear();
		var weekday=new Array(7);
		weekday[0]="星期日";
		weekday[1]="星期一";
		weekday[2]="星期二";
		weekday[3]="星期三";
		weekday[4]="星期四";
		weekday[5]="星期五";
		weekday[6]="星期六";
		var b = d.toLocaleTimeString();
		document.getElementById('myTime').innerHTML = year + "年" + month + "月" + day+"日"+"&nbsp;<br>"+weekday[d.getDay()]+b;
	}
	//时分秒
	function mytime(){
		var d=new Date(format);
		var day=d.getDate();
		d.setSeconds(d.getSeconds()+1);
		format = d;
		var month=d.getMonth() + 1;
		var year=d.getFullYear();
		var weekday=new Array(7);
		weekday[0]="星期日";
		weekday[1]="星期一";
		weekday[2]="星期二";
		weekday[3]="星期三";
		weekday[4]="星期四";
		weekday[5]="星期五";
		weekday[6]="星期六";
		var b = d.toLocaleTimeString();
		document.getElementById('myTime').innerHTML = year + "年" + month + "月" + day+"日"+"&nbsp;<br>"+weekday[d.getDay()]+b;
	}
	setInterval(function() {mytime()},1000);
	</script>
</head>

<%
	User people = (User) request.getSession().getAttribute("currentUser");
    String name = null;
    if(people != null){
      name = people.getUserName();
    }
%>
<script type="text/html" id="rowToolbar">
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="back">带回</a>
</script>
<body>
   
   <table style="width: 99.6%; text-align: center; margin: 0px; padding: 0px;" border="1px solid #000">
   		<tr>
   			<td rowspan="2" width="30%"><img alt="" src="${pageContext.request.contextPath }/img/logo.png" width="60%"></td>
   			<td rowspan="2" width="30%" style="background-color: #4472C4"><p class="font1">拆端盖工位</p></td>
   			<td width="20%"><p class="font2" style="background-color: #4472C4; color: #ffffff">操作人</p></td>
   			<td rowspan="2"width="20%" style="background-color: #4472C4;"><a id="myTime"  class="font2"></a><a id="time1" class="font2"></a></td>
   		</tr>
   		<tr>
   			<td class="font2" style="background-color: #4472C4; color: #ffffff" id="people"><%=name%></td>
   		</tr>
   		<tr>
   			<td rowspan="2" class="font3" style="color:  #4472C4">台车扫码</td>
   			<td rowspan="2" class="font3" style="color:  #4472C4">待固化台车</td>
   			<td colspan="2" style="font-family: 微软雅黑; font-size: 36px;line-height: 70px;color:  #4472C4">膜管扫码</td>
   		</tr>
   		
   		<tr>
   			<td colspan="2" style="font-family: 微软雅黑; font-size: 36px; line-height: 70px">
   				<input  id="c1" placeholder="扫码输入框" style="width: 99%;border:1px #FFFFFF solid;text-align: center;">
   			</td>
   		</tr>
   		
   		<tr>
   			<td  class="font3">
   				<input id="g1" name="cremark" placeholder="台车扫码" style="width: 99%;border:1px #FFFFFF solid;text-align: center;">
   			</td>
   			<td rowspan="7">
   				<table style="width: 100%" id="table2">
   					<tr>
   						<td width="20%">01</td>
   						<td id="w1"></td>
   					</tr>
   					<tr>
   						<td>02</td>
   						<td id="w2"></td>
   					</tr>
   					<tr>
   						<td>03</td>
   						<td id="w3"></td>
   					</tr>
   					<tr>
   						<td>04</td>
   						<td id="w4"></td>
   					</tr>
   					<tr>
   						<td>05</td>
   						<td id="w5"></td>
   					</tr>
   					<tr>
   						<td>06</td>
   						<td id="w6"></td>
   					</tr>
   					<tr>
   						<td>07</td>
   						<td id="w7"></td>
   					</tr>
   					<tr>
   						<td>08</td>
   						<td id="w8"></td>
   					</tr>
   					<tr>
   						<td>09</td>
   						<td id="w9"></td>
   					</tr>
   					<tr>
   						<td>10</td>
   						<td id="w10"></td>
   					</tr>
   				</table>
   			</td>
   			<td class="font3">膜管编码</td>
   			<td class="font3">绑定时间</td>
   		</tr>
   		<tr>
   			<td></td>
   			<td rowspan="6" colspan="2">
   				<table style="width: 100%" id="table3">
   					<tr>
   						<td width="10%">01</td>
   						<td width="40%" id="m1"></td>
   						<td id="t1"></td>
   					</tr>
   					<tr>
   						<td>02</td>
   						<td id="m2"></td>
   						<td id="t2"></td>
   					</tr>
   					<tr>
   						<td>03</td>
   						<td id="m3"></td>
   						<td id="t3"></td>
   					</tr>
   					<tr>
   						<td>04</td>
   						<td id="m4"></td>
   						<td id="t4"></td>
   					</tr>
   					<tr>
   						<td>05</td>
   						<td id="m5"></td>
   						<td id="t5"></td>
   					</tr>
   					<tr>
   						<td>06</td>
   						<td id="m6"></td>
   						<td id="t6"></td>
   					</tr>
   					<tr>
   						<td>07</td>
   						<td id="m7"></td>
   						<td id="t7"></td>
   					</tr>
   					<tr>
   						<td>08</td>
   						<td id="m8"></td>
   						<td id="t8"></td>
   					</tr>
   					<tr>
   						<td>09</td>
   						<td id="m9"></td>
   						<td id="t9"></td>
   					</tr>
   					<tr>
   						<td>10</td>
   						<td id="m10"></td>
   						<td id="t10"></td>
   					</tr>
   					<tr>
   						<td>11</td>
   						<td id="m11"></td>
   						<td id="t11"></td>
   					</tr>
   					<tr>
   						<td>12</td>
   						<td id="m12"></td>
   						<td id="t12"></td>
   					</tr>
   				</table>
   			</td>
   		</tr>
   		<tr>
   			<td class="font11" style="background-color: #4472C4;border-width: 10px; border-color: #ffffff;height: 60px;" id="repair">设备报修</td>
   		</tr>
   		<tr>
   			<td class="font11" style="background-color: #4472C4;border-width: 10px; border-color: #ffffff;height: 60px;" id="bad">配件报检</td>
   		</tr>
   		<tr>
   			<td class="font11" style="background-color: #4472C4;border-width: 10px; border-color: #ffffff;height: 60px;" id="technics">工艺卡</td>
   		</tr>
   		<tr>
   			<td class="font11" style="background-color: #4472C4;border-width: 10px; border-color: #ffffff;height: 60px;" id="job">作业管理</td>
   		</tr>
   		<tr>
   			<td class="font11" style="background-color: #676767;border-width: 10px; border-color: #ffffff;height: 60px;" id="back">注销</td>
   		</tr>
   		<tr>
   			<td></td>
   			<td><button class="font4" style="background-color: #4472C4;color: #ffffff; width: 200px" onclick="agv()">AGV拉动</button></td>
   			<td colspan="2"><button class="font4" style="background-color: #4472C4;color: #ffffff; width: 200px" id="subBut">绑定结束</button></td>
   		</tr>
   </table>
   
   <div id="peiDivID" hidden="hidden">
   
	   	<div class="demoTable" style="padding:10px 0 0 15px">
			<label class="layui-form-label">配件名称</label>
		    <div class="layui-inline">
		    	<input class="layui-input" name="searchName" id="searchName" placeholder="" style="display: inline; width: 80%">
		    </div>
		    <button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload" id="serch"><i class="layui-icon layui-icon-search">  搜索</i></button>
		</div>
		<table class="layui-hide" id="peiList" lay-filter="peiList"></table>
	</div>
   
   <div id="ngDivID" hidden="hidden">
	<form class="layui-form layui-card-body" id="formID" action="${pageContext.request.contextPath}/ng/insert.do">
	  	<input type="hidden" name="istation" value="拆端盖">
	  	<div class="layui-form-item">
			<label class="layui-form-label">条码</label>
			<input class="layui-input" lay-verify="type" type="text" name="icode" id="icode" style="width:200px;">
		</div>
   		<div class="layui-form-item">
   			<div class="layui-inline">
				<label class="layui-form-label">配件名称</label>
				 <div class="layui-input-inline">
					<input class="layui-input" type="text" name="iname" id="iname" lay-verify="iname" style="width:200px;" onclick="pei()">
				</div>
			</div>
			<div class="layui-inline">
				<font style="color:red; font-size: 24px;">*</font>
		    </div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">配件规格</label>
			<div class="layui-input-block">
 				<input class="layui-input"  lay-verify="type" type="text" name="istandard" id="istandard" style="width:200px;">
 			</div>
		</div>
		<div class="layui-form-item"><label class="layui-form-label">配件批次号</label><input class="layui-input" lay-verify="type" type="text" name="ibatch" id="ibatch" style="width:200px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">配件数量</label><input class="layui-input" lay-verify="type" type="text" name="inum" id="inum" style="width:200px;"></div>
  		<div class="layui-form-item">
  			<label class="layui-form-label">异常描述</label>
  			<div class="layui-input-inline" style="width:200px;">
                <input type="text" name="idescription" id="idescription" class="layui-input" style="position:absolute;z-index:2;width:80%;" lay-verify="idescription" onkeyup="search()" autocomplete="off">
		      	<select type="text" id="hc_select"  lay-filter="hc_select" autocomplete="off" class="layui-select" lay-search>
		      	</select>
  			</div>
  			<div class="layui-inline">
				<font style="color:red; font-size: 24px;">*</font>
		    </div>
  		</div>
  		
  		 <div class="layui-form-item">
		    <label class="layui-form-label">是否推送</label>
		    <div class="layui-input-block">
		      <input type="checkbox" name="remark01" lay-skin="switch" lay-text="ON|OFF">
		    </div>
		  </div>
  		
  		<button class="layui-btn layui-btn-blue" lay-submit lay-filter="subform" id="save" style="margin-left:120px; margin-bottom: 20px">提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" id="cz" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button>
	</form>
</div>
</body>
<script type="text/javascript">
$(function(){
    var index;
    /* $("#add").click(function(){ */
    $("body").on("click", "#add", function() {
        //console.log($(this).parents('tr').get(0));
        var rowId = $(this).parents('tr').attr("id");
        //alert(rowId);
        var tbody = document.getElementById("tbody");
        index = tbody.rows.length + 1;
        var tab = document.getElementById('myTable');
        //指定行号
        var rowNumNext = document.getElementById(rowId).rowIndex + 1;
        //在指定行下插入一行
        var tr = tab.insertRow(rowNumNext);
        //给tr设置动态Id和样式
        tr.id = "tr" + index;
        tr.style = "text-align: center";
        //在行下插入列内容
        var cell0 = tr.insertCell(0);
        var cell1 = tr.insertCell(1);
        var cell2 = tr.insertCell(2);
        var cell3 = tr.insertCell(3);
        var cell4 = tr.insertCell(4);

        cell0.innerHTML = '<td><input class="layui-input" id="changeDeviceName" name="changeDeviceName" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell1.innerHTML = '<td><input class="layui-input" id="deviceVersion" name="deviceVersion" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell2.innerHTML = '<td><input class="layui-input" id="deviceCount" name="deviceCount" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell3.innerHTML = '<td><input class="layui-input" id="deviceUnit" name="deviceUnit" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell4.innerHTML = '<td><i class="layui-icon layui-icon-add-1" id="add" style="font-size: 15px; color: #1E9FFF;"></i><br><i class="layui-icon layui-icon-close" id="recover" style="font-size: 15px; color: #1E9FFF; font-weight: bold;"></i></td>';
    });

    $("body").on("click", "#recover", function() {
        var rowId = $(this).parents('tr').attr("id");
        $("#"+rowId).remove();
    })
});
</script>
<script>
layui.use(['table','layer','upload','form','laydate'], function(){
	  var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
	  var table = layui.table;
	  var layer = layui.layer;
	  var laydate = layui.laydate;
	  var form = layui.form; 
	  form.render();
	  
	  form.on('select(hc_select)', function (data) {   //选择移交单位 赋值给input框
          $("#idescription").val(data.value);
          $("#hc_select").next().find("dl").css({ "display": "none" });
          form.render();
      });

      window.search = function () {
          var value = $("#idescription").val();
          $("#hc_select").val(value);
          form.render();
          $("#hc_select").next().find("dl").css({ "display": "block" });
          var dl = $("#hc_select").next().find("dl").children();
          var j = -1;
          for (var i = 0; i < dl.length; i++) {
              if (dl[i].innerHTML.indexOf(value) <= -1) {
                  dl[i].style.display = "none";
                  j++;
              }
              if (j == dl.length-1) {
                  $("#hc_select").next().find("dl").css({ "display": "none" });
              }
          }
          
      }
	  
	  
	  var $ = layui.jquery, active = {
		reload:function () {
			var searchName = $("#searchName").val();
			table.reload('contenttable',{
				method:'get',
				where:{"paname":searchName},
				page:{
					curr:1  //重新从第一页开始
				}
			});
		}
	  }
	  
	  $('.layui-btn').on('click', function(){
	      var type = $(this).data('type');
	      active[type] ? active[type].call(this) : '';
	  });
	  
	  table.render({
		    elem: '#peiList'
		    ,url:'${pageContext.request.contextPath }/partMana/listPagePart.do'
		    ,title: '配件列表'
		    ,id :'contenttable'
		    ,limits:[10,20,30]
		    ,cols: [[
				      {field:'paname', title:'配件名称',width:200},
				      {field:'panum', title:'配件编号' ,width:150},
				      {field:'pamodel', title:'配件规格',width:200},
				      {field:'paremark1', title:'计量单位',width:100},
				      //{field:'paremark2', title:'包装规格',width:100},
				      {fixed:'right', title:'操作', toolbar: '#rowToolbar', width:80}
				    ]],
		    page: true,
		});
	  
	  table.on('tool(peiList)', function(obj){
			var data = obj.data;
			console.log(obj)
			if(obj.event === 'back'){
				
			    $("#iname").val(obj.data.paname); 
			    $("#istandard").val(obj.data.pamodel); 
			    var id = obj.data.paid;
			    $.ajax({
			    	type:'post',
			    	data: {"id":id},
			    	url:'/solid/selectPcByPaid.do',
			    	success:function(data){
			    		$("#ibatch").val(data); 
			    	}
			    });
			    if($("#iname").val() != null ) {
			    	layer.close(index); 
			    }
			    
			}
		});
	  
	  $.ajax({
	        type: "post",
	        url: "${pageContext.request.contextPath }/json/options.json",
	        dataType: 'JSON',
	        success: function (data) {
	              //设置下拉列表中的值的属性
	       		 $("#hc_select").append('<option value="">请选择</option>'); 
	              for ( var i = 0; i < data.length; i++) {
	            	  //增加下拉列表。
	            	  $("#hc_select").append("<option>"+data[i].name+"</option>");
	            	  form.render('select');
	              }
	        }
	  	});
	  
	//提交
	  $('#subBut').click(function(){   
		 var stube1 = $("#m1").text();
		 
		 if(stube1 == "" || stube1 == undefined || stube1 == null) {
			 toastr.warning("台车灭有绑定任何膜管，请扫膜管条码！");
			 return;
		 }else {
		 
			 var taiche=$.trim($("#g1").val());
				
			//判断页面是否有空的
			if(taiche == "" || taiche == undefined || taiche == null) {
				return;
			}else {
				for (var i = 1; i<inpK; i++) {
				 var stube = $("#m"+i).text();
				 var time = $("#t"+i).text();
				 
				//批量提交
				 $.ajax({
			    	type:'post',
			    	async:true, 
			    	url:'${pageContext.request.contextPath }/solid/save.do',
			    	data: {"cremark":taiche,"stube":stube,"cremark1":time},
			    	success:function(data){
			    		if(data>0){
			    		}else{
			    			toastr.warning("绑定失败！");
			    			return;
			    		}
			    	}
			    });
			  }
				toastr.success("绑定成功！");
				selectWaitTc();
				$("#g1").val("");
				$("#c1").val("");
				for (var i = 0; i < 13; i++) {
					$("#m"+i).text("");
					$("#t"+i).text("");
				}
				inpK = 1;
				//input 结束数字
				inpJ = 12;
				//input 开始id
				id = "g1";
				flag = 0;
				$("#g1").focus(); 
				$("#g1").select(); 
				
			}
		 }
	});
  
  //设备报修
 $('#repair').click(function(){   
	 layer.open({
         type: 1 					//Page层类型
         ,area: ['50%', '83%'] 	//宽  高
         ,title: '设备报修'
         ,shade: 0.6 				//遮罩透明度
         ,maxmin: true 				//允许全屏最小化
         ,anim: 1 					//0-6的动画形式，-1不开启
         //,content: $("#addFormID")
         ,content: '<form class="layui-form" id="addFormID">'+
         '<table>'+
         '<tr>'+
             '<td><label class="layui-form-label left-label" style="margin-top: 20px;width:150px;" >设备编号</label></td>'+
             '<td>'+
                 '<div>'+
                     '<div style="width: 200px; margin-left: 0px; float: left; margin-top: 20px">'+
                         '<select class="layui-select" id="deviceNo" name="deviceNo" lay-filter="displayInfo" lay-verify="deviceNo">'+
                             '<option value="">请选择</option>'+
                         '</select>'+
                     '</div>'+
                     '<div style="margin-top: 29px; float: left">'+
                         '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
                     '</div>'+
                 '</div>'+
             '</td>'+ 					
             '<td><label class="layui-form-label left-label" style="margin-top: 20px;width:150px;">故障设备名称</label></td>'+
             '<td><input type="text" id="deviceName" name="deviceName" lay-verify="deviceName" class="layui-input" style="width:200px; margin-top: 20px; display: inline;">' +
                 '<div class="layui-inline" style="margin-top: 4px;">'+
                     '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
                 '</div>'+
             '</td>'+
         '</tr>'+
         '<tr style="height:10px"></tr>'+
         '<tr>'+
             '<td><label class="layui-form-label left-label" style="width:150px;">报修部门/车间</label></td>'+
             '<td>'+
                 '<div>'+
                     '<div style="width: 200px; margin-left: 0px; float: left">'+
                         '<select class="layui-select" id="repairDept" name="repairDept" lay-verify="repairDept">'+
                             '<option value="">请选择</option>'+
                         '</select>'+
                     '</div>'+
                     '<div style="margin-top: 9px; float: left">'+
                         '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
                     '</div>'+
                 '</div>'+
             '</td>'+
             '<td><label class="layui-form-label left-label" style="width:150px;">报修人</label></td>'+
             '<td><input type="text" name="repairMan" id="repairMan" value="<%= name%>" class="layui-input" style="width:200px"></td>'+
         '</tr>'+
         '<tr style="height:10px"></tr>'+
         '<tr>'+
             '<td><label class="layui-form-label left-label"  style="width:150px;">报修时间</label></td>'+
             '<td><input type="text" name="repairTime" id="repairTime"  class="layui-input" style="width:200px"></td>'+
             '<td></td>'+
             '<td></td>'+
         '</tr>'+
         '<tr style="height:10px"></tr>'+
         '<tr>'+
             '<td><label class="layui-form-label left-label" style="width:150px;">故障现象描述</label></td>'+
             '<td colspan="3"><textarea class="layui-textarea" id="errorDescribe" name="errorDescribe" style="width: 540px; height: 150px;"></textarea></td>'+
         '</tr>'+
         '<tr style="height:10px"></tr>'+
         '<tr>'+
             '<td colspan="2">' +
                 '<label class="layui-form-label" style="width:150px;">审批人</label>' +
                 '<input readonly class="layui-input" lay-verify="approvalPeople" placeholder="请选择审批人" name="approvalPeople" id="approvalPeople" type="text" style="width:100px; display:inline; margin-left: 19px">' +
                 '<i style="font-size:15px;" id="refresh" class="layui-icon layui-icon-refresh"></i>' +
                 '<ul id="treeConfig" class="ztree" style="margin-left: 120px;"></ul>'+
             '</td>'+
             '<td colspan="2">' +
                 '<label class="layui-form-label" style="width:150px;">抄送人</label>' +
                 '<input readonly class="layui-input" lay-verify="ccPeople" placeholder="请选择三个抄送人" name ="ccPeople" id="ccPeople" type="text" style="width:200px; display:inline">' +
                 '<i style="font-size: 15px;" id="dCopyMenRefresh" class="layui-icon layui-icon-refresh"></i>'+
                 '<ul id="dCopyMenConfig" class="ztree" style="margin-left: 100px;"></ul>'+
             '</td>'+
         '</tr>'+
         '<tr style="height:20px"></tr>'+
         '<tr align="center">'+
             '<td colspan="2"><button class="layui-btn layui-btn-blue" id="subBtn" lay-submit lay-filter="addForm" style="margin-left:160px; margin-bottom: 20px">提交</button>&emsp;&emsp;'+
             '<td colspan="2"><button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button>'+
         '<tr>'+
     '</table>'+
 '</form>'
     
        ,success: function(){
        	
        	 //报修时间
            laydate.render({
                elem: '#repairTime'
            });
            //维修起始时间
            laydate.render({
                elem: '#fixStartTime'
            });
            //维修结束时间
            laydate.render({
                elem: '#fixEndTime'
            });
            //验收日期
            laydate.render({
                elem: '#acceptTime'
            });

            //下拉查找所有设备
            $.ajax({
                type: 'POST',
                url: '${pageContext.request.contextPath}/device/queryAllDeviceList.do',
                dataType: 'json',
                async: false,
                success: function (data){
                    for (var i = 0; i < data.length; i++) {
                        $("#deviceNo").append("<option value='"+ data[i].deviceNo +"'>"+ data[i].deviceNo +"</option>");
                    }
                }
            });
            //下拉框查找所有部门
            $.ajax({
                type: 'POST',
                url: '${pageContext.request.contextPath}/device/queryAllDeptList.do',
                dataType: 'json',
                async: false,
                success: function (data){
                    for (var i = 0; i < data.length; i++) {
                        $("#repairDept").append("<option value='"+ data[i].name +"'>"+ data[i].name +"</option>");
                    }
                }
            });

            $("#refresh").click(function(){
                $("#approvalPeople").val("");
            })
            $("#dCopyMenRefresh").click(function(){
                $("#ccPeople").val("");
            })

            var setting = {
                isSimpleData : true,             //数据是否采用简单 Array 格式，默认false
                treeNodeKey : "id",              //在isSimpleData格式下，当前节点id属性
                treeNodeParentKey : "pId",       //在isSimpleData格式下，当前节点的父节点id属性
                showLine : true,                 //是否显示节点间的连线
                checkable : true,                //每个节点上是否显示 CheckBox
                data: {
                    simpleData: {
                        enable: true,
                        idKey: "id",
                        pIdKey: "pId",
                        rootPid: "0"
                    }
                },
                callback: {
                    onDblClick: onDblClick,
                }
            };

            var dCopyMenSetting = {
                isSimpleData : true,              //数据是否采用简单 Array 格式，默认false
                treeNodeKey : "id",               //在isSimpleData格式下，当前节点id属性
                treeNodeParentKey : "pId",        //在isSimpleData格式下，当前节点的父节点id属性
                showLine : false,                 //是否显示节点间的连线
                data: {
                    simpleData: {
                        enable: true,
                        idKey: "id",
                        pIdKey: "pId",
                        rootPid: "0"
                    }
                },
                callback: {
                    onDblClick: dCopyMenOnDblClick,
                }
            };

            function onDblClick(e,treeId,treeNode) {

                selectedNode = treeNode;
                var name = treeNode.name;
                var id = treeNode.id;
                var type = treeNode.type;
                if(type!="-1"){
                    var dApprover1 = $("#approvalPeople").val();
                    var dApprovers = dApprover1.split(",");
                    for(var i=0;i<dApprovers.length;i++){
                        if(name==dApprovers[i]){
                            toastrStyle();
                            toastr.warning("选择了重复的审批人！")
                            name = "";
                        }
                    }
                    var dApprover2;
                    if(dApprover1 == "" && name != ""){
                        dApprover2 = $("#approvalPeople").val((dApprover1+','+name).substring(1));
                    }else if(name != ""){
                        dApprover2 = $("#approvalPeople").val(dApprover1+','+name);
                    }
                    var dApprover3 =  $("#approvalPeople").val();
                    var dApprovers3 = dApprover3.split(",");
                    var dApprovers3Length = dApprovers3.length;
                    if(dApprovers3.length>1){
                        toastr.warning("最多选择1个审批人");
                        $("#approvalPeople").val(dApprover1);
                    }
                }else{
                    toastrStyle();
                    toastr.warning("请选择审批人！")
                }
            }

            function dCopyMenOnDblClick(e,treeId,treeNode) {
                dCopyMenSelectedNode = treeNode;
                var name = treeNode.name;
                var id = treeNode.id;
                var type = treeNode.type;

                var dCopyMen = $("#ccPeople").val();
                var dCopyMen = dCopyMen.split(",");
                for(var i=0;i<dCopyMen.length;i++){
                    if(name==dCopyMen[i]){
                        toastrStyle();
                        toastr.warning("选择了重复的抄送人！")
                        name = "";
                    }
                }
                if(dCopyMen == "" && name != ""){
                    dCopyMen = $("#ccPeople").val((dCopyMen+','+name).substring(1));
                }else if(name != ""){
                    dCopyMen = $("#ccPeople").val(dCopyMen+','+name);
                }
            }

            $.ajax({
                type:'get',
                url:'${pageContext.request.contextPath }/disposeRejects/getZtreeJson.do',
                dataType:'json',
                success: function(data){
                    var	zNodes = data.rows;
                    $(document).ready(function() {
                        $.fn.zTree.init($("#treeConfig"), setting, zNodes);
                    });
                },
                error: function(){
                    toastrStyle();
                    toastr.error("请求失败");
                }
            });

            $.ajax({
                type:'get',
                url:'${pageContext.request.contextPath }/disposeRejects/getZtreeJson.do',
                dataType:'json',
                success: function(data){
                    var	dCopyMenzNodes = data.rows;
                    $(document).ready(function() {
                        $.fn.zTree.init($("#dCopyMenConfig"), dCopyMenSetting, dCopyMenzNodes);
                    });
                },
                error: function(){
                    toastrStyle();
                    toastr.error("请求失败");
                }
            });

            //初始化radio、select等元素
            form.render();
        }
      });
  })
  
   //注销
  $('#back').click(function(){   
	  window.location.href="${pageContext.request.contextPath }/logout.do";
   });
  
 //工艺卡
 $('#technics').click(function(){  
	window.location.href="${pageContext.request.contextPath }/jumpPage/craftDetails.do";
  })
  
  //作业管理
 $('#job').click(function(){   
	 //传值：工位
	window.location.href="${pageContext.request.contextPath }/jumpPage/workManage.do?positionName=拆端盖";
});
  
   //产品报检
  $('#producCheck').click(function(){   
	  window.location.href="${pageContext.request.contextPath }/cut/enterProductInspectionPage.do";
   })
   
    //配件报检
 $('#bad').click(function(){   
	 layer.open({
	   type: 1 					//Page层类型
  		,area: ['450px', '650px'] 	//宽  高
  		,title: '配件报检'
  		,shade: 0.6 				//遮罩透明度
  		,maxmin: true 				//允许全屏最小化
  		,anim: 1 					//0-6的动画形式，-1不开启
  		,content: $("#ngDivID")
  		,end: function(){
  			$("#ngDivID").hide();
  			$("#g1").focus(); 
  		}
   		,success: function(layero, index){
   			$("#cz").click();
   			form.render();
   			
   			$("#icode").focus(); 
   			
	       	 this.enterEsc = function(event){
		          if(event.keyCode === 13){
		            return false; //阻止系统默认回车事件
		          }
	        }; 
	        $(document).on('keydown', this.enterEsc);	//监听键盘事件，关闭层
	    }
   	});
  })
  
	/**
      * 新增表单校验
      */
     form.verify({
         //value：表单的值item：表单的DOM对象
         deviceName: function(value, item){
             if(value == ''){
                 return '设备名称不能为空';
             }
         },
         deviceNo: function(value, item){
             if(value == ''){
                 return '设备编号不能为空';
             }
         },
         repairDept: function(value, item){
             if(value == ''){
                 return '报修部门不能为空';
             }
         },
         iname: function(value, item){
             if(value == ''){
                 return '配件名称不能为空';
             }
         },
         idescription: function(value, item){
             if(value == ''){
                 return '异常描述不能为空';
             }
         },
     });

  
    /**
      * 设备报修
      */
     form.on('submit(addForm)', function (data) {
    	 $("#subBtn").attr("disabled",true);
         $.ajax({
             url : '${pageContext.request.contextPath}/breakdown/addDeviceBreakdown.do',
             data: $("#addFormID").serialize(),
             cache : false,
             type : "post",
         }).done(
             function(res) {
                 if (res > 0) {
                     toastr.success('报修成功！');
                     layer.closeAll();
                 }
             }
         ).fail(
             function(res) {
                 toastr.error('报修失败！');
                 layer.closeAll();
             }
         )
         return false;
     });
  
	//查找带回
  form.on('select(displayInfo)', function(data){
  	$.ajax({
          type: 'POST',
          url: '${pageContext.request.contextPath}/device/queryDeviceInfoByNo.do',
          data: {deviceNo:$('#deviceNo').val()},
          success: function (data){
          	var device = eval('(' +data+ ')');
          	$('#deviceName').val(device.deviceName);
          }
      });
  });
  
	//配件报检
  form.on('submit(subform)', function (data) {
	 
	  $("#save").attr("disabled",true);
	  
	  var datas=data.field;
   	  var action=data.form.action;
   	  $.ajax({
   		  url:action,
   		  data:datas,
   		  type:"POST",
   		  dataType:"json",
   		  success:function(result){
   			 if(result > 0) {
   				toastr.success("报检成功！");
   				$("#reset").click();
   				layer.closeAll();
   			 }else {
   				 toastr.warning("报检失败！");
   				 return false;
   			 }
   		  },
   	  });
   	  
   	  return false;
	  });
  
  toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
  toastr.options.timeOut = '2000'; //自动关闭时间
});
</script>
</html>